package com.zxt.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zxt.pojo.Books;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper
public interface BookMapper extends BaseMapper<Books> {
    //增加一本书
    @Update("insert into ssmbuild.books (bookName, bookCounts, detail)\n" +
            "        values (#{bookName},#{bookCounts},#{detail})")
    int addBook(Books books);

    //删除一本书
//    @Delete("delete from ssmbuild.books where bookID = #{bookID}")
//    int deleteBookById(@Param("bookID") int id);

    //更新一本书
//    @Update("update ssmbuild.books\n" +
//            "        set bookName = #{bookName},bookCounts=#{bookCounts},detail=#{detail}\n" +
//            "        where bookID=#{bookID}")
//    int updateBook(Books books);

    //查询一本书
    @Select("select * from ssmbuild.books where bookID=#{bookID}")
    Books queryBookById(@Param("bookID")int id);

    //查询全部的书
//    @Select("select * from ssmbuild.books")
//    List<Books> queryAllBooks();

    //模糊查询书籍
    @Select("select * from ssmbuild.books where bookName like concat(concat('%',#{name}),'%')")
    List<Books> queryBooksByName(String name);
}
